﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <meta charset="utf-8" />

    <title></title>
    <link href="autoSearchText.css" type="text/css" rel="Stylesheet" />
    <script src="jquery-1.5.1.js" type="text/javascript"></script>
    <script src="jquery.autoSearchText.js" type="text/javascript"></script>
    <script src="mock.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#aSt1').autoSearchText({ itemsid: "autoSearchItem1", itemswidth: 300, itemsHeight: 150, datafn: getData, callBackfn: alertMsg, datafnPara2: "Text",copyobj: "copydata"});
            $('#aSt2').autoSearchText({ datafn: getData,  datafnPara2: "Text" });
            $('#aSt3').autoSearchText({ datafn: getData });
        });
        function alertMsg(vl) {
            alert('搜索結果為： ' + vl);
        }
        /*加载数据*/
        function getData(val, DType) {
            var arrData = new Array();
            if (val == "") return arrData;
            Mock.mock("getData.ashx?DataType=" + DType, [{ "id": "1", "Code": "1374123" }, { "id": "2", "Code": "1374133" }, { "id": "3", "Code": "1374143" }, { "id": "4", "Code": "1374153" }, { "id": "5", "Code": "1374163" }, { "id": "6", "Code": "1374173" }, { "id": "7", "Code": "1374183" }, { "id": "8", "Code": "1374193" }, { "id": "9", "Code": "1374213" }, { "id": "10", "Code": "1374223" }, { "id": "11", "Code": "1374233" }, { "id": "12", "Code": "1374243" }, { "id": "13", "Code": "1374253" }, { "id": "14", "Code": "1374263" }, { "id": "15", "Code": "1374273" }, { "id": "16", "Code": "1374283" }, { "id": "17", "Code": "1374293" }, { "id": "18", "Code": "1374313" }, { "id": "19", "Code": "1374323" }, { "id": "20", "Code": "1374333" }, { "id": "21", "Code": "1374343" }, { "id": "22", "Code": "1374353" }, { "id": "23", "Code": "1374363" }, { "id": "24", "Code": "1374373" }, { "id": "25", "Code": "1374383" }, { "id": "26", "Code": "1374393" }, { "id": "27", "Code": "1374403" }, { "id": "28", "Code": "1374413" }, { "id": "29", "Code": "1374423" }, { "id": "30", "Code": "1374433" }, { "id": "31", "Code": "1374443" }, { "id": "32", "Code": "1374453" }, { "id": "33", "Code": "1374463" }, { "Code": "1374473", "id": "34" }, { "id": "35", "Code": "1374483" }, { "id": "36", "Code": "1374493" }]);
            $.ajax({
                type: "post",
                async: false, //控制同步
                url: "getData.ashx?DataType=" + DType,
                data: "param=" + val,
                dataType: "json",
                cache: false,
                success: function (data) {
                    for (var i = 0; i < data.length; i++) {
                        if (val == data[i].Code.substring(0, val.length))
                            arrData.push(data[i].Code);
                    }
                },
                Error: function (err) {
                    alert(err);
                }
            });
            return arrData;
        }
    </script>
</head>
<body>
    <div>
        全部參數<input id="aSt1" type="text" placeholder="请输入编码" />
		<div>同步數據<input id="copydata" type="text" placeholder="同步中。。。" /></div>
        部分參數<input id="aSt2" type="text" placeholder="请输入编码" />
        最少參數<input id="aSt3" type="text" placeholder="请输入编码" />
    </div>
</body>
</html>
